<?php
include_once '../inc/config.inc.php';
include_once '../inc/mysqli.inc.php';
include_once '../inc/tool.inc.php';
//var_dump($_SERVER); exit();
if(!isset($_GET['id'])||!is_numeric($_GET['id'])){
    skip('fatherModule.php','error','id参数错误！ ');
}
$link=connect();
$query="select *from fatherModule where id={$_GET['id']}";
$result=execute($link,$query);
if(!mysqli_num_rows($result)){
    skip('fatherModule.php','error','板块信息不存在！ ');
}
$data=mysqli_fetch_assoc($result);
$data=dehtml($data);

if(isset($_POST['submit'])){
    $link=connect();
    $cheekflag='update';
include_once 'inc/checkinfo.inc.php';
    $query="update fatherModule set moduleName='{$_POST['moduleName']}',sort={$_POST['sort']} where id={$_GET['id']}" ;
    $result=execute($link,$query);
    if(mysqli_affected_rows($link)){
        skip('fatherModule.php','ok','修改成功！');
    }elseif($data['moduleName']==$_POST['moduleName']&&$data['sort']==$_POST['sort']){
        skip('fatherModule.php','attention','数据未作修改！');
    }
    else{
        skip("$_SERVER[REQUEST_URI]",'error','修改失败，请重试！ ');
    }
}
?>
<?php
$template='修改父板块';
include_once 'inc/header.inc.php';
?>
 <div id="main">
        <div class="intro"><?php echo $template ?></div>  
        <form method="post">   
            <table class="au"> 
                <tr>
                    <td>板块名称</td>
                    <td><input type="text" name="moduleName" value="<?php echo $data['moduleName'] ?>"></td>
                    <td><span>* 板块名称不得为空，最大不超过40个字符</span></td>
                </tr>
                <tr>
                    <td>排&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;序</td>
                    <td><input type="text" name="sort" value="<?php echo $data['sort'] ?>"></td>
                    <td><span>填写一个数字</span> </td>
                </tr>
            </table>
            <input type="submit" name="submit" value="修改" class="nsubmit" />
        </form>
    </div>








<?php
    include_once 'inc/footer.inc.php';
?>